/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.rafkind.crawl.data.team;

import com.rafkind.crawl.battle.BattleCommand;
import com.rafkind.crawl.battle.command.AttackCommand;
import com.rafkind.crawl.battle.command.DefendCommand;
import com.rafkind.crawl.data.Creature;
import com.rafkind.crawl.data.Team;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 *
 * @author drafkind
 */
public class MonsterTeam extends Team {
  
  private Random random = new Random();

  @Override
  public BattleCommand getBattleCommandFor(Creature creature) {
    Team opponents = creature.getOpposingTeam();
    
    Creature best = null;
    for (Creature t : opponents.getMembers()) {
      if (t.isActiveInBattle()) {
	if (best == null || best.getHitPoints() > t.getHitPoints()) {
	  best = t;
	}
      }
    }
    
    if (best == null) {
      return new DefendCommand(creature);
    } else {
      List<Creature> ell = new ArrayList<Creature>();
      ell.add(best);
      return new AttackCommand(random, creature, ell);
    }
  }
}